<% content_for :sitemap do %>
  <span class="current">OAuth 应用</span>
<% end %>

<div class="toolbar">
  <form class="form-inline" action="<%= admin_applications_path %>">
    <div class="form-group">
      <input type="text" name="q" class="form-control" value="<%= params[:q] %>" placeholder="名称" />
    </div>
    <div class="form-group">
      <%= select_tag(:level, options_for_select([['全部 Level',''], ['Level 0', 0], ['Level 1', 1], ['Level 2', 2], ['Level 3', 3]], params[:level]), class: 'form-control') %>
    </div>
    <button class="btn btn-default">搜索</button>
  </form>
</div>

<div id="admin_applications">
  <table class="table table-bordered table-striped table-condensed">
    <tr class="head">
      <th>编号</th>
      <th>名称</th>
      <th>uid</th>
      <th>Owner</th>
      <th>Tokens</th>
      <th>Level</th>
      <th>创建时间</th>
      <th class="opts"></th>
    </tr>
    <% @applications.each do |item| %>
    <tr class="<%= cycle("","even") %>">
      <td><%= item.id %></td>
      <td><%= link_to item.name, admin_application_path(item.id) %></td>
      <td><%= item.uid %></td>
      <td><%= user_name_tag(item.owner) %></td>
      <td><%= item.access_tokens.count %></td>
      <td><%= item.level %></td>
      <td><%= l(item.created_at, format: :long) %></td>
      <td>
        <%= link_to '修改', edit_admin_application_path(item) %>
      </td>
    </tr>
    <% end %>
  </table>

  <%= paginate @applications %>
</div>
